rest_delete_{$this->post_type}
Action HookDescription
Fires immediately after a single post is deleted or trashed via the REST API. They dynamic portion of the hook name, `$this->post_type`, refers to the post type slug. Possible hook names include: - `rest_delete_post` - `rest_delete_page` - `rest_delete_attachment`Hook Information
File Location |
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
View on GitHub
|
Hook Type | Action |
Line Number | 1186 |
Hook Parameters
Type | Name | Description |
---|---|---|
WP_Post
|
$post
|
The deleted or trashed post. |
WP_REST_Response
|
$response
|
The response data. |
WP_REST_Request
|
$request
|
The request sent to the API. |
Usage Examples
Basic Usage
<?php
// Hook into rest_delete_{$this->post_type}
add_action('rest_delete_{$this->post_type}', 'my_custom_function', 10, 3);
function my_custom_function($post, $response, $request) {
// Your custom code here
}
Source Code Context
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php:1186
- How this hook is used in WordPress core
<?php
1181 *
1182 * @param WP_Post $post The deleted or trashed post.
1183 * @param WP_REST_Response $response The response data.
1184 * @param WP_REST_Request $request The request sent to the API.
1185 */
1186 do_action( "rest_delete_{$this->post_type}", $post, $response, $request );
1187
1188 return $response;
1189 }
1190
1191 /**
PHP Documentation
<?php
/**
* Fires immediately after a single post is deleted or trashed via the REST API.
*
* They dynamic portion of the hook name, `$this->post_type`, refers to the post type slug.
*
* Possible hook names include:
*
* - `rest_delete_post`
* - `rest_delete_page`
* - `rest_delete_attachment`
*
* @since 4.7.0
*
* @param WP_Post $post The deleted or trashed post.
* @param WP_REST_Response $response The response data.
* @param WP_REST_Request $request The request sent to the API.
*/
Quick Info
- Hook Type: Action
- Parameters: 3
- File: wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
Related Hooks
Related hooks will be displayed here in future updates.